package backtracking;

import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;

/**
 * @ Author     ：侯耀祖
 * @ Description：
 */
public class subset {
    List<List<Integer>> result = new ArrayList<>();
    LinkedList<Integer> path = new LinkedList<>();
    public List<List<Integer>> subsets(int[] nums) {
        backtracking(nums, 0);
        return result;
    }
    public void backtracking(int[] num, int start){
        if (start <= num.length){
            result.add(new ArrayList<>(path));
        } else {
            return;
        }
        for (int i = start; i < num.length; i++) {
            path.add(num[i]);
            backtracking(num, i + 1);
            path.removeLast();
        }
    }
}
